﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>relipmoC: em deaR</title>
    <style type="text/css">

div.Section1
	{page:Section1;}
 p.MsoNormal
	{margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";
	        margin-left: 0in;
            margin-right: 0in;
            margin-top: 0in;
        }
p
	{margin-right:0in;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman","serif";
	}
p.style2
	{margin-right:0in;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Calibri","sans-serif";
	font-weight:bold;
        }
span.style31
	{font-family:"Calibri","sans-serif";
	}
span.style21
	{font-family:"Calibri","sans-serif";
	font-weight:bold;
        }
        .style2
        {
            font-family: "Courier New", Courier, monospace;
        }
        .style3
        {
            text-decoration: none;
        }
        .style7
        {
            font-family: Verdana;
            font-size: medium;
        }
        .style8
        {
            font-family: "Century Gothic";
        }
        .style9
        {
            font-family: "Century Gothic";
            font-weight: bold;
        }
        .style10
        {
            font-family: "Century Gothic";
            font-style: italic;
        }
        .style11
        {
            font-family: Calibri;
            text-decoration: underline;
            font-weight: bold;
            font-size: 13.5pt;
        }
    </style>
</head>
<body lang="EN-US" link="blue" style="tab-interval: .5in" vlink="purple" 
    bgcolor="#99ffcc">

<div class=Section1>

<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"' 
        class="style10">relipmoC</span><span
style='mso-fareast-font-family:"Times New Roman"' class="style8"> is an assembly to 
    C translator. Its a naive decompiler which cannot yet handle programs containing 
    pointers, structures and goto</span><span
style='font-family:"Century Gothic","sans-serif";mso-fareast-font-family:"Times New Roman"'>
    </span><span
style='mso-fareast-font-family:"Times New Roman"' class="style8">
    statements</span><span
style='font-family:"Century Gothic","sans-serif";mso-fareast-font-family:"Times New Roman"'>
    </span><span
style='mso-fareast-font-family:"Times New Roman"' class="style8">
    that cannot be converted into equivalent </span><i><span
style='font-family:"Courier New";mso-fareast-font-family:"Times New Roman"'>for</span></i><span
style='font-family:"Century Gothic","sans-serif";mso-fareast-font-family:"Times New Roman"'>
    </span><span
style='mso-fareast-font-family:"Times New Roman"' class="style8">
    and</span><span
style='font-family:"Century Gothic","sans-serif";mso-fareast-font-family:"Times New Roman"'>
    </span><i><span style='font-family:"Courier New";mso-fareast-font-family:
"Times New Roman"'>while</span></i><span style='font-family:"Century Gothic","sans-serif";
mso-fareast-font-family:"Times New Roman"'> </span>
    <span style='mso-fareast-font-family:"Times New Roman"' class="style8"> loops</span><span style='font-family:"Century Gothic","sans-serif";
mso-fareast-font-family:"Times New Roman"'>.</span><span
style='mso-fareast-font-family:"Times New Roman"'><o:p></o:p></span></p>

<p>&nbsp;</p>

<p class=style2><u><span style='font-size:13.5pt'>REQUIREMENTS</span></u></p>

<p class="style8">Any version of Linux
supporting <i style='mso-bidi-font-style:normal'>gcc</i> (preferably
3.2.2),&nbsp; <i style='mso-bidi-font-style:normal'>g++</i> (3.2.2 or higher), <i
style='mso-bidi-font-style:normal'>Flex</i> and <i style='mso-bidi-font-style:
normal'>Yacc</i> (optional) and the <i style='mso-bidi-font-style:normal'>indent</i>
(optional) programs. </p>

<p><span class="style8">The <i>indent</i>
program is used to indent the decompiled C program generated by <i>relipmoC</i>.
If its not available then use the</span><span style='font-family:"Century Gothic","sans-serif"'> </span><span class="style2">--noindent</span><span style='font-family:"Century Gothic","sans-serif"'> </span>
    <span class="style8"> option at the command line
and the output will not be indented, and you will find it hard to read the
output of </span> <em><span class="style8"> relipmoC</span><span style='font-family:"Century Gothic","sans-serif"'> </span> </em><span
class=style31>:-)</span></p>

<p><i style='mso-bidi-font-style:normal'><span class="style8">indent</span></i><span 
        class="style8"> program is provided by GNU.
Get it from</span></p>

<p class=style7>
    <a href="http://mysite.freeserve.com/indent/indent_2.2.9.tar.gz" 
        class="style3" hreflang="en-us" lang="en-us" shape="rect">http://mysite.freeserve.com/indent/indent_2.2.9.tar.gz</a></p>

<p class=style7>
    <a href="http://mysite.wanadoo-members.co.uk/indent/indent_2.2.9.tar.gz" 
        class="style3" hreflang="en-us" lang="en-us">http://mysite.wanadoo-members.co.uk/indent/indent_2.2.9.tar.gz</a></p>

<p class=style2>&nbsp;</p>
    <p class=style11>MAN PAGE</p>

<p><span style='font-family:&#039;Century Gothic&#039;'>We have included a
man page for at gives a brief idea about the various options
available under <i>relipmoC</i>. The man page is named </span></p>

<p><b><span style='font-family:"Century Gothic","sans-serif"'>relipmoC.1</span></b></p>

<p><span style='font-family:&#039;Century Gothic&#039;'>&nbsp;To view the
man page say, (from the directory containing the man page)</span></p>

<p><b><span style='font-family:"Century Gothic","sans-serif"'>$</span></b><span
style='font-size:13.5pt;font-family:"Courier New"'>man ./relipmoC.1 </span></p>

<p><span style='font-family:&#039;Century Gothic&#039;'>If you are the
super-user and if you want to install it so that you can view it from any
directory, copy the man page to</span></p>

<p><span style='font-size:13.5pt;font-family:"Courier New"'>/usr/share/man/man1</span><span
style='font-family:"Century Gothic","sans-serif"'> </span></p>

<p class="style8" lang="en-us">then just say, </p>

<p><b><span style='font-family:"Century Gothic","sans-serif"'>$</span></b><span
style='font-size:13.5pt;font-family:"Courier New"'>man relipmoC</span></p>

<p>&nbsp;</p>

<p class=style2><u><span style='font-size:13.5pt'>COMPILING THE PROJECT</span></u></p>

<p><span class="style8">If</span><span style='font-family:"Century Gothic","sans-serif"'> </span><i><span
style='font-family:"Courier New"'>lex</span></i><span style='font-size:13.5pt;
font-family:"Century Gothic","sans-serif"'> </span><span class="style8">and</span><span style='font-size:13.5pt;
font-family:"Century Gothic","sans-serif"'> </span><i><span style='font-family:
"Courier New"'>yacc</span></i><span style='font-size:13.5pt;font-family:"Century Gothic","sans-serif"'>
</span><span class="style8">are available
then just say (in the directory containing the source of <em>relipmoC)</em></span><span style='font-family:"Century Gothic","sans-serif"'>,</span></p>

<p><b><span style='font-family:"Century Gothic","sans-serif"'>$</span></b><span
style='font-size:13.5pt;font-family:"Courier New"'>make</span></p>

<p><span class="style8">otherwise use the
following command to compile,</span><span style='font-size:13.5pt;font-family:
"Century Gothic","sans-serif"'> </span><span style='font-size:13.5pt;'> 
    <br class="style8">
    </span><span style='font-size:13.5pt;font-family:
"Century Gothic","sans-serif"'> 
<b><u><br>
</u>$</b></span><span style='font-size:13.5pt;font-family:"Courier New"'>make
-f noLexYacc.mak</span></p>

<p class="style8">The makefile has
been written assuming that the compilation is being done by the super user.
Modify it if required.</p>

<p class="style8">After compiling, an
executable file named &quot;relipmoC&quot; will be obtained, which is the
assembly to C translator.</p>

<p><span class="style9">If there are any
problems while compiling please write to us.<br>
</span><span style='font-family:"Century Gothic","sans-serif"'><br>
    </span><span class="style8">Anyway, we have provided a statically linked executable named</span></p>

<p><b><span style='font-size:13.5pt;font-family:"Courier New"'>relipmoC_static</span></b></p>

<p class="style8">This can be used for
decompilation and you can do away with compiling the project.</p>

<p>&nbsp;</p>

<p><span class=style31><b><u><span style='font-size:13.0pt'>HOW TO DECOMPILE?</span></u></b></span><b><u><span
style='font-size:13.0pt;font-family:"Century Gothic","sans-serif"'><br>
<br>
</span></u></b><span class="style8">To
decompile an assembly program</span><span style='font-family:"Century Gothic","sans-serif"'> </span><i><span style='font-size:13.5pt;
font-family:"Courier New"'>hello.s</span></i><span style='font-family:"Century Gothic","sans-serif"'><br>
<br>
<b>$</b></span><span style='font-size:13.5pt;font-family:"Courier New"'>relipmoC
hello.s<br>
</span><span style='font-family:"Century Gothic","sans-serif"'><br>
    </span><span class="style8">By default the decompiled</span><span style='font-family:"Century Gothic","sans-serif"'> </span><i><span style='font-size:13.5pt;font-family:
"Courier New"'>hello.s</span></i><b><span style='font-size:13.5pt;font-family:
"Courier New"'> </span></b><span class="style8">program
will be stored in the file</span><span style='font-family:"Century Gothic","sans-serif"'> </span><i><span style='font-size:13.5pt;font-family:
"Courier New"'>hello.s.c</span></i><span style='font-family:"Century Gothic","sans-serif"'>&nbsp;
i.e.,&nbsp; </span><i><span style='font-size:13.5pt;font-family:"Courier New"'>program_name.s.c</span></i><span
style='font-family:"Century Gothic","sans-serif"'> in
general.<br>
The decompiled source will have just one header file named </span></p>

<p><b><span style='font-size:13.5pt;font-family:"Courier New"'>ourHeader.h</span></b></p>

<p><span class="style8">This
&quot;includes&quot; any system header files that might have been used. If you
have used a header file not included in&nbsp; </span><i><span style='font-size:
13.5pt;font-family:"Courier New"'>ourHeader.h</span></i><strong><span
style='font-size:13.0pt;font-family:"Courier New"'> </span></strong>
    <span class="style8">then you can modify</span><span
style='font-family:"Century Gothic","sans-serif"'> </span><i><span
style='font-size:13.5pt;font-family:"Courier New"'>ourHeader.h</span></i><span
style='font-family:"Century Gothic","sans-serif"'> </span><span class="style8"> accordingly. The file </span><i><span
style='font-size:13.5pt;font-family:"Courier New"'>ourHeader.h</span></i><span
style='font-family:"Century Gothic","sans-serif"'> 
</span><span class="style8"> can either be included in
the</span><span
style='font-family:"Century Gothic","sans-serif"'><br>
</span><span class="style8"> directory, <br>
</span><span
style='font-family:"Century Gothic","sans-serif"'> 
<br>
</span><span style='font-size:13.5pt;font-family:"Courier New"'>/usr/include/<br>
</span><span style='font-family:"Century Gothic","sans-serif"'><br>
    </span><span class="style8">provided that this in the &quot;PATH&quot; environment variable.<br>
OR<br>
you can modify &quot;PATH&quot; to include the current directory.</span></p>

<p>&nbsp;</p>

<p class=style2><u><span style='font-size:13.5pt'>HOW TO OBTAIN THE ASSEMBLY
PROGRAM OF A C PROGRAM?</span></u></p>

<p><b><u><span style='font-size:13.5pt;font-family:"Century Gothic","sans-serif"'><br>
</span></u></b><span class="style8">To get
the assembly program of a C program named </span><i><span style='font-size:
13.5pt;font-family:"Courier New"'>hello.c</span></i><span style='font-family:
"Century Gothic","sans-serif"'><br>
<br>
<b>$</b></span><span style='font-size:13.5pt;font-family:"Courier New"'>cc
hello.c&nbsp;-S<br>
</span><span style='font-family:"Century Gothic","sans-serif"'><br>
    </span><span class="style8">By default the assembly program will be stored in the file </span><i><span
style='font-size:13.5pt;font-family:"Courier New"'>hello.s</span></i><span
style='font-family:"Century Gothic","sans-serif"'><br>
    </span><span class="style8">The gcc compiler performs some optimizations, in such cases 
    <i>relipmoC</i> may fail.
In such cases you can turn off the optimizations by,</span></p>

<p><b><span style='font-family:"Century Gothic","sans-serif"'>$</span></b><span
style='font-size:13.5pt;font-family:"Courier New"'>cc hello.c -S -O0</span><span
style='font-family:"Century Gothic","sans-serif"'><br>
&nbsp;</span></p>

<p><span class="style10">relipmoC</span><span class="style8"> assumes that the assembly
program being decompiled has been obtained by compiling a C program by gcc3.2.2
compiler. You may think that this is very restrictive but its not. Look at it
this way, a compiler is written for a specific programming language. So you
cannot use a C compiler to compile a PASCAL program. The reason is that the
compiler assumes the input to be in a particular format and this format is specified
by the language grammar. Similarly, a decompiler is written for an assembly
program in a particular format and in the case of </span><span
style='font-family:"Century Gothic","sans-serif"'> <em><span class="style8">relipmoC</span></em></span><span 
        class="style8"> its the format specified by
the gcc3.2.2 compiler. However its not very difficult to port it to other
versions of the gcc compiler as most of the instructions are similar across the
versions. </span></p>

<p>&nbsp;</p>

<p><span class=style21><u><span style='font-size:13.5pt'>TEST CASES</span></u></span><br>
<span class="style8">As we have specified
above, we assume that the assembly program to be decompiled has been obtained
by compiling a C program using gcc3.2.2 compiler.<br>
Anyway, we have provided a few sample programs all compiled using the gcc3.2.2
compiler. These are present in the directory <b>test</b>. The directory <b>src</b>
contains the original C code and the directory <b>assembly</b> contains the
corresponding assembly programs to be decompiled. You can use these to test
relipmoC.</span></p>

<p>&nbsp;</p>

<p class=style2><u><span style='font-size:13.5pt'>DOCUMENTATION</span></u></p>

<p><b><u><span style='font-size:13.5pt;font-family:"Century Gothic","sans-serif"'><br>
</span></u></b><span class="style8">The file
<i>synopsis.pdf </i>contains a brief description of the concepts used. The
detailed description of the decompilation techniques used are found in the file</span><span 
        class="style9">
</span><span class="style8">techniques_used.pdf
and is about
60 pages in length.<br>
&nbsp;</span></p>

<p class="style8">We will be happy to
receive any suggestions for improvement. We will also be interested in cases
where <i>relipmoC </i>fails to decompile. You can contact us at </p>

<p class="style8"><a
href="mailto:arjun_singri@yahoo.com">arjunsingri@gmail.com</a></p>

<p class="style8"><a
href="mailto:darshandd@gmail.com">darshandd@gmail.com</a></p>

</div>

</body>
</html>
